import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { DeviceMetaRequestDto } from '../../devices/dto/device-meta.dto';
import { AuditStatus } from '../../common/enums';

/**
 * DTO for preinstalled license request
 */
export class PreinstalledLicenseRequestDto {
  @ApiProperty({
    description: '审核编号',
    example: 'AUDIT-12345678',
  })
  @IsNotEmpty()
  @IsString()
  auditNumber: string;

  @ApiProperty({
    description: '校验码',
    example: 'VERIFY-87654321',
  })
  @IsNotEmpty()
  @IsString()
  verifyCode: string;

  @ApiProperty({
    description: '设备序列号',
    example: 'SN12345678',
  })
  @IsNotEmpty()
  @IsString()
  deviceSerialNumber: string;

  @ApiProperty({
    description: '设备元数据',
    type: DeviceMetaRequestDto,
    required: true,
  })
  @IsNotEmpty()
  @ValidateNested()
  @Type(() => DeviceMetaRequestDto)
  deviceMeta: DeviceMetaRequestDto;
}

/**
 * DTO for preinstalled license response
 */
export class PreinstalledLicenseResponseDto {
  @ApiProperty({
    description: '审核状态',
    enum: AuditStatus,
    example: AuditStatus.PASS,
  })
  status: AuditStatus;
}

/**
 * DTO for audit status request
 */
export class AuditStatusRequestDto {
  @ApiProperty({
    description: '设备序列号',
    example: 'SN12345678',
  })
  @IsNotEmpty()
  @IsString()
  deviceSerialNumber: string;
}

/**
 * DTO for audit status response
 */
export class AuditStatusResponseDto {
  @ApiProperty({
    description: '审核状态',
    enum: AuditStatus,
    example: AuditStatus.PASS,
  })
  status: AuditStatus;
}
